package com.example.exampleproject.view;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.exampleproject.R;
import com.example.exampleproject.base.BaseActivity;
import com.example.exampleproject.injection.component.DaggerMainActivityComponent;
import com.example.exampleproject.presenter.MainPresenter;


public class MainActivity extends BaseActivity<MainPresenter> implements IMainView{

    private TextView mainTxt;
    private Button mainBtn;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainTxt = findViewById(R.id.main_txt);
        mainBtn = findViewById(R.id.main_btn);
        mainBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPresenter.requestWeather();
            }
        });

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void inject() {
        DaggerMainActivityComponent.create().inject(this);
    }

    @Override
    public void showWeather(String weatherMessage) {
        mainTxt.setText(weatherMessage);
    }
}
